This is where we get to be a little more creative with our programming. We will go back to our basic Monte Carlo routine so as to keep the coding as simple as possible.
The things you will need to consider when programming exotic options are:
There is ultimately no limit to the amount of different options you could consider, but we will look at a few key ones here. The point is once you can program then you can change your code to reflect any particular option you want.
A single barrier option is typically an option which pays out zero unless it has reached a certain level. Once it has reached that level then it acts as a normal option.
You can have options which are up-and-in, up-and-out, down-and-in and down-and-out.
For example if we turned our standard option into a down and out option with a knock-out point of £90 then it would behave just like any other call option unless the price of the underlying share went below £90, at any point, at which point the option would become worthless.
So you need an extra variable say knocked_out as boolean.
Initially you set this to false:
knocked_out = false
Then you will need to work out where to add the lines:
if S < 90 then knockout_out = true end if
What would be wrong with
if S < 90 then knockout_out = true else knocked_out = false end if
It would effectively knock back in again when the share price rose above 90
What else will you need to change
At the end you will need
if knocked_out then payoff = 0 else payoff = max(S - K, 0) 'or whatever the payoff is end if
The other types of option follow by analogy.
Whereas for a standard call option the payoff would be $Max(S_n - K, 0)$, for a digital option the payoff could be $I(S_n > K)$, that is the payoff is £1 if the share price is above the strike price and nothing otherwise.
The code for this would need to be something like:
if S > K then payoff = 1 'or whatever payoff is else payoff = 0 end if
You could also write an actual indicator function, but this would probably be overkill
function indicator(condition as boolean) as double if condition then indicator = 1 else indicator = 0 end if end function
Notice here how we have used the boolean variable - this can only take values true or false
We can also set the return value of the function in the middle of the function if we wish as is shown above
You CANNOT use the return value as an interim variable though as the function will think this is a further function call
Lookback option can come in many forms, but the classic variety is for example an option where instead of the payout being $Max(S_n - K, 0)$ it might be $Max\left(\displaystyle Max_{0 \leq i\leq n}(S_i) - K, 0\right)$, so you have to "look back" over the price evolution of the share to calculate the payoff of the option.
To include lookback options you will need an extra variable which 'carries' the look back amount
For example the line:
if S > max_S then max_S = S
will use the variable max_S to store the running maximum value of the share price
What else do you need to do
Make sure max_S is reset to 0 for the start of each run
Make sure you use max_S and not S in your payoff function at the end
Adapt your Monte Carlo model code so that it can handle Barrier options, digital options and look-back options. You need to use the function: Monte_Carlo_LogNormal
American Options cannot be simply priced by Monte Carlo methods
Why do you think this is the case
It follows from the fact that the valuation of American options using binomial tress requires us to work backwards through the tree given that at each point in time we need to decide whether or not to exercise given the relative values of the 'intrinsic' and 'carry-on' values
It may help to review the Binomial tree method for American option pricing
American Options allow the holder to exercise at any time up to and including maturity.
When you do a CRR tree you need to adapt your code so that at each node you calculate two different values:
Check out the code in this spreadsheet: Binomial Model to see how American Options are handled
Remember how we worked out the payoff at the end and then for each node decide if we would have exercised at that point given the follow-on value
Clearly there is little point in being able to price American call options (on non-dividend paying shares) as they have the same price as the European Call option. We will largely just consider Put options from now on
There are some methods available for approximating American option prices using Monte Carlo methods.
A comprehensive paper by Caflish and Chaudary of UCLA is presented here for further reading.
I have given a simple but slow method and a surprisingly fast but more difficult method below
The critical decision method is based on the idea that (for simple call and put options) we can divide the decision space into (for put options):
and visa versa for call options
where we need to work out what the threshold values $Y_t$ are, for each $t$ for which we are allowed to make a decision
A Spreadsheet can be found here. It includes a very simple evolutionary search method
Ultimately can be used to produce arbitrarily accurate results
Extremely slow
Only uses discrete decision points, which although there can be arbitrarily many of them will make an already slow method even slower
Using the same set of random numbers for each threshold $Y_{t_{i}}$ will make comparison converge quicker
Efficient selection of $Y_{t_{i}}$ will allow optimum to be found more quickly
This method which can also be called the least squares method, can only ultimately produce an approximation but is much faster and has been tested to produce remarkably accurate results
The essence is to fit a quadratic (or some other appropriate function) to the follow-on values as you go backwards through the set of all the Monte Carlo runs
A common function for $f$ is $f(a + b \times X + c \times X^2) = Y$ where $X$ is the vector of share prices at time $t_{i}$ and $Y$ is the payoffs discounted back to $t_{i}$ from $t_{i+1}$
The slide show below illustrates the method